package com.loyal.loyalerp.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import com.loyal.loyalerp.humenresource.askleave.model.vo.Check;
import com.loyal.loyalerp.humenresource.kaoqinMonth.model.vo.CompanyIdAndAskVO;
import com.loyal.loyalerp.model.ChangeInitData;
import com.loyal.loyalerp.model.KaoQinMessage;
import com.loyal.loyalerp.model.RsCheck;
import com.loyal.loyalerp.model.vo.CompanyIdAndYears;
import com.loyal.loyalerp.model.vo.ExcelVo;
import com.loyal.loyalerp.model.vo.PersonBaseData;
import com.loyal.loyalerp.model.vo.PersonIdAndYear;
import com.loyal.loyalerp.model.vo.UsernameAndWork;
@Mapper

public  interface KaoQinMapper {
	
	//根据personId删除该条记录
	@Delete("delete from rs_kaoqin where personid=#{personId}")
	void deleteKaoqinByPersonId(Integer personId);
	
	//companyId+personId+KjYear+Period+Days插入到考勤表中
	void updateByCPYPD(CompanyIdAndAskVO caVO);
	
	//通过主键id查询用户id
	@Select("select PersonId from rs_kaoqin where id = #{value}")
	int selectPersonIdById(int id);
	
   public List<PersonBaseData> selectAllPerson(int companyid);
   //初始化员工考勤期初数
   public void insertPersonInit(KaoQinMessage msg);
   //判断当前年份有没有被定义过
   public int selectYearHasInit(CompanyIdAndYears com);
   //查看所有员工期初信息
   public List<KaoQinMessage> selectAllPersonInitData(String flag);
   //根据用户姓名查询考勤信息
   public List<KaoQinMessage> selectPersonKaoQinByName(UsernameAndWork vo);
   //获取员工上年剩余年假
   public float selectPersonHasLastHoliday(PersonIdAndYear model);
   //判断员工是否有剩余年假
   public int PersonIsExistLastHoliday(PersonIdAndYear model);
   //查看该公司是否有员工
   public int isHasPerson(int companyId);
   //更新期初数据
   public void updateInitData(ChangeInitData data);
   //初始化数据时往审核表中添加公司信息
   public void insertCompanyCheck(RsCheck check);
   //查询期初数据弃审
   public int selectAbandonCheck(CompanyIdAndYears year);
   //查看期数数据审核
   public int selectInitDataCheck(CompanyIdAndYears year);
   //审核
   public void updateAbandonCheck(CompanyIdAndYears year);
   //弃审
   public void updateIsCheck(CompanyIdAndYears year);
   //根据公司id和年份查询期初信息
   public List<KaoQinMessage> selectInitDataByCompanyIdAndYears(CompanyIdAndYears year);
   //恢复审核
   public void updateIsNoCheck(CompanyIdAndYears year);
   //删除所有考勤记录
   public void deleteAllRecord();
   
   //获得所有员工期初信息（导出excel）
   public List<KaoQinMessage> selectAllPersonInitDataByExcel(ExcelVo vo);
   
   //根据员工id和年份获得期初数据
   public KaoQinMessage selectInitDataByPersonIdAndYears(Check check);
   
   //请年假
   public void updateKaoQinDataToYear(Check check);
   
   //请事假
   public void updateKaoQinDataToPerson(Check check);
   
   //请病假
   public void updateKaoQinDataToSick(Check check);
   
   //弃审年假
   public void qishenKaoQinDataToYear(Check check);
   
   //弃审事假
   public void qishenKaoQinDataToPerson(Check check);
   
   //弃审病假
   public void qishenKaoQinDataToSick(Check check);
   
   //根据主键查询期初信息
   public KaoQinMessage selectInitDataByPrimaryKey(int id);
}
